package cn.itsource.ymcc.openfeign.factory;

import cn.itsource.ymcc.domain.CourseDoc;
import cn.itsource.ymcc.openfeign.SearchCourseOpenfeign;
import cn.itsource.ymcc.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class SearchCourseOpenfeignFallbackFactory implements FallbackFactory<SearchCourseOpenfeign> {
    @Override
    public SearchCourseOpenfeign create(Throwable throwable) {
        return new SearchCourseOpenfeign() {
            @Override
            public JsonResult save(CourseDoc courseDoc) {
                throwable.printStackTrace();//写了这个可以在控制台里面看
                return JsonResult.error(throwable.getMessage());
            }

            @Override
            public JsonResult save(List<CourseDoc> courseDoc) {
                System.out.println(throwable.getMessage());
                throwable.printStackTrace();//写了这个可以在控制台里面看
                return JsonResult.error(throwable.getMessage());
            }

            @Override
            public JsonResult save(Long id) {
                throwable.printStackTrace();//写了这个可以在控制台里面看
                return JsonResult.error(throwable.getMessage());
            }

            @Override
            public JsonResult query() {
                throwable.printStackTrace();//写了这个可以在控制台里面看
                return JsonResult.error(throwable.getMessage());
            }

            @Override
            public JsonResult queryCourseDoc(Long courseId) {
                throwable.printStackTrace();//写了这个可以在控制台里面看
                return JsonResult.error(throwable.getMessage());
            }

            @Override
            public JsonResult queryCourseDocByIds(List<Long> ids) {
                throwable.printStackTrace();//写了这个可以在控制台里面看
                return JsonResult.error(throwable.getMessage());
            }
        };
    }
}
